﻿//using System;
//using System.Collections.Generic;
//using System.IO;
//using System.Linq;
//using System.Security.Cryptography;
//using System.Text;
//using System.Threading.Tasks;

//namespace MVA.Book.Chapter_2._2._6
//{
//    class _3_17
//    {
//        public static void Main()
//        {
//            RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
//            string publicKeyXML = rsa.ToXmlString(false);
//            string privateKeyXML = rsa.ToXmlString(true);

//            UnicodeEncoding ByteConverter = new UnicodeEncoding();
//            byte[] dataToEncrypt = ByteConverter.GetBytes("My Secret Data!");
//            byte[] encryptedData;
//            using (RSACryptoServiceProvider RSA = new RSACryptoServiceProvider())
//            {
//                RSA.FromXmlString(publicKeyXML);
//                encryptedData = RSA.Encrypt(dataToEncrypt, false);
//            }
//            byte[] decryptedData;
//            using (RSACryptoServiceProvider RSA = new RSACryptoServiceProvider())
//            {
//                RSA.FromXmlString(privateKeyXML);
//                decryptedData = RSA.Decrypt(encryptedData, false);
//            }
//            string decryptedString = ByteConverter.GetString(decryptedData);
//            Console.WriteLine(decryptedString); // Displays: My Secret Data!
//            foreach (byte b in encryptedData)
//                Console.Write(b.ToString());
//            Console.ReadKey();
//        }
//    }
//}
